package com.mudingkou.mos.common.pojo.response;


/**
 * <p>通用返回结果</p>
 *
 * @author kzc
 * @date 2020/5/2
 */
public class CommonResponse<T> extends BaseResponse {
    /**
     * 数据列表
     */
    protected T data;

    public CommonResponse() {
        super();
    }

    public CommonResponse(T data) {
        success();
        this.data = data;
    }

    public T getData() {
        return data;
    }

    public CommonResponse<T> setData(T data) {
        this.data = data;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof CommonResponse)) {
            return false;
        }

        CommonResponse<?> that = (CommonResponse<?>) o;

        return getData() != null ? getData().equals(that.getData()) : that.getData() == null;
    }

    @Override
    public int hashCode() {
        return getData() != null ? getData().hashCode() : 0;
    }

    public static<T> CommonResponse<T> create(T data){
        return new CommonResponse<>(data);
    }
    public static<T>  CommonResponse<T> create(){
        return new CommonResponse<T>();
    }
}
